package router

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
	"zy4/client/client"
	user "zy4/common/proto"
)

func Login(s *gin.Context) {
	var users struct {
		Name     string `form:"name" json:"name" xml:"name" binding:"required"`
		Password string `form:"password" json:"password" xml:"password" binding:"required"`
	}
	err := s.ShouldBind(&users)
	if err != nil {
		s.JSON(http.StatusOK, gin.H{
			"Code": 500,
			"Data": err.Error(),
		})
		return
	}
	login, err := client.Login(s, &user.LoginReq{
		Name: users.Name,
	})
	if err != nil {
		s.JSON(http.StatusOK, gin.H{
			"Code": 500,
			"Data": err.Error(),
		})
		return
	}
	fmt.Println(login)
	s.JSON(http.StatusOK, gin.H{
		"Code": 200,
		"Data": true,
	})
}
